'''
Created on Mar 3, 2014

@author: Wu Botao
'''

from time import ctime
print '*** Welcome to Metaclasses!'
print '\tMetaclass declaration first.'

class MetaC(type):
    def __init__(cls, name, bases, attrd):
        super(MetaC, cls).__init__(name, bases, attrd)
        print '*** Created class %r at: %s' % (name, ctime())
        print '\tClass "Foo" declaration next.'
        
class Foo(object):
    __metaclass__ = MetaC
    def __init__(self):
        print '*** Instantiated class %r at: %s' % (self.__class__.__name__, ctime())
        print '\tClass "Foo" instantiation next.'
        
f = Foo()
print '\tDONE'


def __init__(self):
    self.message = 'Hello World'

def say_hello(self):
    print self.message

attrs = {'__init__': __init__, 'say_hello': say_hello}
bases = (object,)
Hello = type('Hello', bases, attrs)

h = Hello()
h.say_hello()


